package com.financing.platform.dao.impl;

import java.sql.SQLException;

import org.springframework.stereotype.Repository;

import com.financing.platform.dao.IUserAccountDao;
import com.financing.platform.dto.ActivitieGiftDTO;
import com.financing.platform.dto.UserAccountDTO;
import com.financing.platform.dto.UserAccountDetailDTO;
import com.financing.platform.util.SqlName;


@Repository("userAccountDaoImpl")
public class UserAccountDaoImpl extends BaseDaoImpl implements IUserAccountDao {

	public int addUserAccount(UserAccountDTO userAccountDTO)
			throws SQLException {
		return  (Integer) this.sqlMapClient.insert(SqlName.addUserAccount, userAccountDTO);
	}

	public int updateUserAccount(UserAccountDTO userAccountDTO)
			throws SQLException {
		return this.sqlMapClient.update(SqlName.updateUserAccount, userAccountDTO);
	}
	public int updateAccountBalanceActivity(UserAccountDTO userAccountDTO)
			throws SQLException {
		return this.sqlMapClient.update(SqlName.updateAccountForWithdraw, userAccountDTO);
	}

	public int addUserAccountDetail(UserAccountDetailDTO userAccountDetailDTO)
			throws SQLException {
		return (Integer) this.sqlMapClient.insert(SqlName.addUserAccountDetail,userAccountDetailDTO);
	}
	
	public int insertUserAccountDetail(UserAccountDetailDTO userAccountDetailDTO)
			throws SQLException {
		return (Integer) this.sqlMapClient.insert(SqlName.insertUserAccountDetail,userAccountDetailDTO);
	}
	
	public int getUserAccountId(String userId) {
		try {
			return (Integer) this.sqlMapClient.queryForObject(SqlName.getUserAccountId,userId);
		} catch (SQLException e) {
			log.error("query user account id error ",e);
			return -1;
		}
	}

	public int thawingAccountMount(ActivitieGiftDTO activitieGiftDTO)
			throws SQLException {
		return this.sqlMapClient.update(SqlName.thawingAccountMount,activitieGiftDTO);
	}

	@Override
	public int addAccountMount(ActivitieGiftDTO activitieGiftDTO)
			throws SQLException {
		return this.sqlMapClient.update(SqlName.addAccountMount, activitieGiftDTO);
	}
	
	

}
